package com.zjitc;

import com.zaxxer.hikari.HikariDataSource;
import com.zjitc.obj.User;
import java.sql.Connection;
import java.sql.SQLException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/3/6 14:06
 * @description:
 */
public class App2 {

  public static void main(String[] args) {
    HikariDataSource dataSource=null;
    try{
      dataSource=new HikariDataSource();
      dataSource.setUsername("root");
      dataSource.setPassword("123456789");
      dataSource.setDriverClassName("com.mysql.jdbc.Driver");
      dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/test");

        try {
          Connection connection=dataSource.getConnection();
          System.out.println(connection);
          System.out.println("111");
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }finally {
      if(dataSource!=null)
      {
        dataSource.close();
      }
    }
    ApplicationContext guo=new ClassPathXmlApplicationContext("hikariCP_config.xml");
    User u1 = guo.getBean("u1", User.class);
    System.out.println(u1);
    User u2 = guo.getBean("u2", User.class);
    System.out.println(u2);
    User u3 = guo.getBean("u3", User.class);
    System.out.println(u3);
    User u5 = guo.getBean("u5", User.class);
    System.out.println(u5);
  }


}
